package com.hbsx.why.ui.activity;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.hbsx.why.NormalMainActivity;
import com.hbsx.why.R;
import com.hbsx.why.TabMainActivity;
import com.hbsx.why.adapter.MyPagerAdapter;
import com.hbsx.why.adapter.SpacePagerAdapter;
import com.hbsx.why.base.BaseActivity;
import com.hbsx.why.model.bean.UserBean;
import com.hbsx.why.ui.space.SpaceChildFragment;
import com.hbsx.why.utils.LogUtils;
import com.hbsx.why.views.BackButton;
import com.hbsx.why.views.CoordinatorTabLayout;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by liub
 * time 2017/8/29
 */

public class ActivityActivity extends BaseActivity {
    public static TabMainActivity myTabActivity;
    public static NormalMainActivity myNormalMainActivity;
    @BindView(R.id.tv_topTitle)
    TextView tvTopTitle;
    private static String mTitle;
    private static String BUNDLE_flag = "BUNDLE_flag";
    @BindView(R.id.btn_back)
    BackButton btnBack;
    @BindView(R.id.btn_top_right)
    ImageView btnTopRight;
    @BindView(R.id.space_fragment_viewpage)
    ViewPager mViewPager;
    @BindView(R.id.space_CoordinatorTabLayout)
    CoordinatorTabLayout mCoordinatorTabLayout;
    private int flag;
    private Context context;
    private List<Fragment> mFragments;
    private List<UserBean> userBeanList;
    private UserBean userBean;


    @Override
    protected void initView() {
        tvTopTitle.setText("活动");
        //btnTopRight.setVisibility(View.VISIBLE);
        context = this;
        Glide.with(context).load(R.mipmap.ic_search_white).into(btnTopRight);
        // btnTopRight.setBackgroundDrawable(getResources().getDrawable(R.mipmap.ic_search));
        initFragments();
        initViewPager();

    }

    @OnClick({R.id.btn_top_right})
    public void onViewClicked() {

    }

    private void initFragments() {
        userBeanList = new ArrayList<>();
        mFragments = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            userBean = new UserBean();
            if (i == 0) {
                userBean.setName("演出");
            }
            if (i == 1) {
                userBean.setName("亲子");
            }
            if (i == 2) {
                userBean.setName("讲座");
            }
            if (i == 3) {
                userBean.setName("展览");
            }
            if (i == 4) {
                userBean.setName("公益电影");
            }
            if (i == 5) {
                userBean.setName("培训");
            }
            if (i == 6) {
                userBean.setName("聚会");
            }
            if (i == 7) {
                userBean.setName("赛事");
            }
            if (i == 8) {
                userBean.setName("读书");
            }
            if (i == 9) {
                userBean.setName("其他");
            }
            mFragments.add(ActivityChildFragment.newInstance("活动" + i, i));
            userBean.setId("" + i);

            userBeanList.add(userBean);
        }

    }

    private void initViewPager() {
        mViewPager.setOffscreenPageLimit(2);
        mViewPager.setAdapter(new MyPagerAdapter(getSupportFragmentManager(), mFragments, userBeanList));
        mCoordinatorTabLayout
                .setBackEnable(true)
                .setupWithViewPager(mViewPager);
    }


    @Override
    protected int getLayoutResId() {
        return R.layout.ui_space_fragment;
    }

}
